package com.example.demo.controller;

import com.example.demo.AiService.ConsultantService;
import dev.langchain4j.model.openai.OpenAiChatModel;
import dev.langchain4j.service.spring.AiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

@RestController
public class ChatController {


    @Autowired
    private ConsultantService consultantService;


    @RequestMapping(value = "/chat",produces = "text/html;charset=utf-8")
    public Flux<String> chat(@RequestParam("memoryId") String memoryId,@RequestParam("message") String message){
        Flux<String> result = consultantService.chat(memoryId,message);
        return result;
    }

//    @Autowired
//    private OpenAiChatModel model;
//    *
//     * 浏览器传递用户问题
//     * @param msg
//     * @return
//
//    @RequestMapping("/chat")
//    public String chat(@RequestParam("msg") String msg) {
//        String res = model.chat(msg);
//        return res;
//    }
}
